package com.example.easy.Service.Impl;

import com.example.easy.Dto.FoodSafety;
import com.example.easy.Dto.Notice;
import com.example.easy.Service.myservice.FoodSafetyServise;
import com.example.easy.Service.myservice.NoticeServise;
import com.example.easy.mapper.FoodSafetyMapper;
import com.example.easy.mapper.NoticeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FoodSafetyServiselmpl implements FoodSafetyServise {

    @Autowired
    FoodSafetyMapper foodSafetyMapper;


    @Override
    public int insFoodSafety(FoodSafety foodSafety) {
        return foodSafetyMapper.insFoodSafety(foodSafety);
    }

    @Override
    public int updateFoodSafety(FoodSafety foodSafety) {
        if (foodSafetyMapper.selectFoodSafety(foodSafety.getNumber()) != null) {
            foodSafetyMapper.updateFoodSafety(foodSafety);
            return 1;
        } else return 0;
    }

    @Override
    public int deleteFoodSafety(int number) {
        if (foodSafetyMapper.selectFoodSafety(number) != null) {
            foodSafetyMapper.deleteFoodSafety(number);
            return 1;
        }else return 0;
    }

    @Override
    public FoodSafety selectFoodSafety(int number) {
        if (foodSafetyMapper.selectFoodSafety(number)!=null){
            return  foodSafetyMapper.selectFoodSafety(number);

        }else return null;

    }

    @Override
    public List<FoodSafety> selectall() {
        return foodSafetyMapper.selectall();
    }
}
